package cn.kgc.springmvcday02.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author 课工场
 * @date 2023/10/16
 * @description
 *   restful
 *  /request/1  get      查询数据
 *  /request    post
 *  /request      put
 *  /request/1     delete
 */
@Controller
@RequestMapping("request")
@SessionAttributes
public class RequestMappingController {

    //  /request/1    /request?id=1
    @GetMapping("{id}")
    public ModelAndView  getMethod(@PathVariable("id") Integer id){

        System.out.println("id = " + id);

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("main");

        System.out.println("get请求被接收");
        return modelAndView;
    }


    @PostMapping
    public ModelAndView  postMethod(){

        System.out.println("post请求被接收");

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("main");


        return modelAndView;
    }

    @PutMapping
    public ModelAndView putMethod(){

        System.out.println("put请求被接收");

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("main");


        return modelAndView;
    }


    @DeleteMapping
    public ModelAndView  deleteMethod(){

        System.out.println("delete请求被接收");

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("main");


        return modelAndView;
    }



}
